package com.ctgu.tengyun.service.product.impl;

import com.ctgu.tengyun.dao.mybatis.ProductGuideInfoMapper;
import com.ctgu.tengyun.domain.ProductGuideInfo;
import com.ctgu.tengyun.domain.ProductGuideInfoExample;
import com.ctgu.tengyun.service.product.ProductGuideInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by liaoweizhi on 2019/7/23.
 */
@Service
public class ProductGuideInfoServiceImpl implements ProductGuideInfoService {

    @Resource
    private ProductGuideInfoMapper mapper;

    @Override
    public void insertSelective(ProductGuideInfo guideInfo) {
        mapper.insertSelective(guideInfo);
    }

    @Override
    public ProductGuideInfo selectByPrimaryKey(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean updateByPrimaryKeySelective(ProductGuideInfo record) {
        return mapper.updateByPrimaryKeySelective(record) > 0;
    }

    @Override
    public List<ProductGuideInfo> selectGuideList(Integer pid) {

        ProductGuideInfoExample example = new ProductGuideInfoExample();
        ProductGuideInfoExample.Criteria criteria = example.createCriteria();

        criteria.andIsValidEqualTo(1);
        if(null  != pid){
            criteria.andPidEqualTo(pid);
        }
        example.setOrderByClause("id desc");

        return mapper.selectByExample(example);
    }
}
